package com.edisoncgh.service.impl;

import com.edisoncgh.dao.UserMapper;
import com.edisoncgh.pojo.User;
import com.edisoncgh.pojo.UserExample;
import com.edisoncgh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService  {

    private UserMapper userMapper;

    @Autowired
    public void setUserMapper(UserMapper userMapper){
        this.userMapper = userMapper;
    }
    @Override
    public boolean addUser(User user) {
        return userMapper.insert(user)>0;
    }

    @Override
    public boolean deleteUserById(Integer id) {
        return userMapper.deleteByPrimaryKey(id)>0;
    }

    @Override
    public boolean updateUser(User user) {
        return userMapper.updateByPrimaryKey(user)>0;
    }

    @Override
    public User findUserById(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> findAllUser() {
        UserExample userExample = new UserExample();
        return userMapper.selectByExample(userExample);
    }
}
